<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/5/14
 * Time: 17:50
 */

namespace app\common\model;


use think\Model;

class Banner extends Model
{
    //自动写入时间戳
    protected $autoWriteTimestamp = true;

    //添加方法
    public function add($data)
    {
        $data['status'] = 1;
        $result = $this -> allowField(true)-> save($data);
        return $result;
    }

    //获取banner信息
    public function getBannerInfo()
    {
        $data=[
            'status' => ['neq',-1],
            ];
        $order=[
            'id' => 'desc',
        ];
        $result = $this -> where($data)
            -> order($order)
            -> select();
        return $result;
    }

    //前台获取banner图
    public function getNormalBannerInfo()
    {
        $data=[
            'status' => 1,
        ];
        $order=[
            'id' => 'desc',
        ];
        $result = $this -> where($data)
            -> order($order)
            -> select();
        return $result;
    }

}